package ma.xin.shi.arxml.export.cherySomeip;

import java.util.Arrays;
import java.util.List;
import ma.xin.shi.ConfigurationManager;
//import static java.util.Arrays.asList;
import java.io.IOException;
import ma.xin.shi.arxml.export.cherySomeip.packages.*;

public class CherySomeipArxmlExportMain {

	//private final ConfigurationManager configManager;

    public CherySomeipArxmlExportMain(ConfigurationManager configMng) {
    	//this.configManager = configMng;
    }

    /**
     * 可供 GUI 调用的方法（无路径参数时，默认输出到 D:/mxs.arxml）
     */
    public static void generateArxml(ConfigurationManager configManager) {
        String defaultOutputPath = "D:/mxs.arxml";
        generateArxml(defaultOutputPath, configManager);
    }

    /**
     * 可供 GUI 调用的方法（指定输出路径）
     *
     * @param outputPath 输出路径
     */
    public static void generateArxml(String outputPath, ConfigurationManager configManager) {
        List<CherySomeipArxmlPackage> packageList = Arrays.asList(
            new CherySomeipArxmlPackageService(configManager),
            new CherySomeipArxmlPackageSoftwareComponent(configManager),
            new CherySomeipArxmlPackageExecutable(configManager),
            new CherySomeipArxmlPackageTopology(configManager),
            new CherySomeipArxmlPackageMachineManifest(configManager),
            new CherySomeipArxmlPackageServiceInstantiation(configManager),
            new CherySomeipArxmlPackageDataTypes(configManager),
            new CherySomeipArxmlPackageMappings(configManager),
            new CherySomeipArxmlPackageClusters(configManager),
            new CherySomeipArxmlPackageModeDeclarationGroups(configManager),
            new CherySomeipArxmlPackageTransformationProps(configManager),
            new CherySomeipArxmlPackageServiceInstance(configManager)
        );

        CherySomeipArxmlExporter exporter = new CherySomeipArxmlExporter(packageList);
        try {
            exporter.export(outputPath);
        } catch (IOException e) {
            System.err.println("❌ 导出失败：" + e.getMessage());
            e.printStackTrace();
        }
    }
}
